/**
 * Copyright (C) 2024-2030 Super BilGen & 超亿时代信息技术股份有限公司.All Rights Reserved.
 */
package cn.com.yang.pdf;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPRow;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;

import cn.com.yang.utils.DateUtil;
import cn.hutool.core.util.NumberUtil;

/**
 * @Model cn.com.yang.pdf.TestPdfImgs
 * @Desc TODO
 * @author yangyijin
 * @since 2025年5月13日-下午7:45:35
 */
public class TestPdfImg2 {
	private Logger logger = LoggerFactory.getLogger(getClass());

	public void exec() {
		StringBuffer fileNameSb = new StringBuffer(DateUtil.localTimeFormat("yyyyMMddHHmmss"));
		fileNameSb.append(System.currentTimeMillis());
		String fileName = fileNameSb.toString();
		StringBuffer pdfFilePathSb = new StringBuffer("/app/file/");
		pdfFilePathSb.append(fileName).append(".pdf");
		try {
			File filePathTmp = new File("/app/file/");
			if (!filePathTmp.exists()) {
				filePathTmp.mkdirs();
			}
			// 生成PDF
			cerateElePdf(pdfFilePathSb.toString());

		} catch (Exception e) {
			logger.error("pdf创建失败：", e);
		}

	}
	
	private void cerateElePdf(String dest) {
		try (FileOutputStream fout = new FileOutputStream(dest)) {
			// 创建文档对象
			Document document = new Document(PageSize.A4);
			Rectangle pageSize = new Rectangle(PageSize.A4.getHeight(),PageSize.A4.getWidth());
			pageSize.rotate();
			document.setPageSize(pageSize);
			// 导出的地址
			PdfWriter writer = PdfWriter.getInstance(document, fout);
			// 打开文档
			document.open();
			BaseFont baseFont = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);

			Font headTitleFont = new Font(baseFont, 16, Font.NORMAL);
			headTitleFont.setColor(BaseColor.GRAY);
			Font headFont = new Font(baseFont, 16, Font.NORMAL);
			headFont.setColor(BaseColor.BLACK);

			Font bodyTitleFont = new Font(baseFont, 14, Font.NORMAL);
			headTitleFont.setColor(BaseColor.GRAY);
			Font bodyFont = new Font(baseFont, 14, Font.NORMAL);
			headFont.setColor(BaseColor.BLACK);
			Font tipFont = new Font(baseFont, 12, Font.NORMAL);
			tipFont.setColor(BaseColor.GRAY);

			// 创建PDF头
			Font titleFont = new Font(baseFont, 20, Font.BOLD);
			titleFont.setColor(BaseColor.BLACK);
			Paragraph titleParagraph = new Paragraph("电子回单", titleFont);
			titleParagraph.setSpacingAfter(18);
			titleParagraph.setAlignment(Element.ALIGN_CENTER);
			document.add(titleParagraph);
			
			createHeadTable(document, headTitleFont, headFont);
			createLine(document);
			createTransTable(document, bodyTitleFont, bodyFont, tipFont);
			
			document.close();
		} catch (Exception e) {
			logger.error("pdf创建失败：", e);
		}
	}

	private void createTransTable( Document document, Font bodyTitleFont, Font bodyFont,
			Font tipFont) throws DocumentException {
		//创建表对象
		PdfPTable transTable = new PdfPTable(6);
		transTable.setHorizontalAlignment(Element.ALIGN_CENTER);
		transTable.setWidthPercentage(100); // 宽度100%填充
		float[] headTableColumnWidths= {0.04f,0.16f,0.3f,0.04f,0.16f,0.3f};
		transTable.setWidths(headTableColumnWidths);
		//设置行对象
		ArrayList<PdfPRow> rows = transTable.getRows();
		//第一行
		PdfPCell rowCell1[] = new PdfPCell[6];
		rowCell1[0]=new PdfPCell(new Paragraph("付款方",bodyTitleFont));
		rowCell1[0].setRowspan(3);//向下合并
		rowCell1[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[0].setMinimumHeight(35);
		rowCell1[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell1[0].setBackgroundColor(new BaseColor(252,228,214));
		
		rowCell1[1]=new PdfPCell(new Paragraph("付款账号",bodyTitleFont));
		rowCell1[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[1].setUseAscender(true);
		rowCell1[1].setMinimumHeight(35);
		rowCell1[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String payerAcctNo = "12321312321312";
		rowCell1[2]=new PdfPCell(new Paragraph(payerAcctNo,bodyFont));
		rowCell1[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[2].setMinimumHeight(35);
		rowCell1[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell1[3]=new PdfPCell(new Paragraph("收款方",bodyTitleFont));
		rowCell1[3].setRowspan(3);//向下合并
		rowCell1[3].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[3].setMinimumHeight(35);
		rowCell1[3].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell1[3].setBackgroundColor(new BaseColor(226,239,218));
		
		rowCell1[4]=new PdfPCell(new Paragraph("收款账号",bodyTitleFont));
		rowCell1[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[4].setMinimumHeight(35);
		rowCell1[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String rcvAcctNo = "21321312312312";
		rowCell1[5]=new PdfPCell(new Paragraph(rcvAcctNo,bodyFont));
		rowCell1[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell1[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[5].setMinimumHeight(35);
		rowCell1[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell1));
		// 第二行
		PdfPCell rowCell2[] = new PdfPCell[6];
		
		rowCell2[1]=new PdfPCell(new Paragraph("付款人名称",bodyTitleFont));
		rowCell2[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell2[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[1].setMinimumHeight(35);
		rowCell2[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String payerAcctName = "张三";
		rowCell2[2]=new PdfPCell(new Paragraph(payerAcctName,bodyFont));
		rowCell2[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell2[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[2].setMinimumHeight(35);
		rowCell2[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell2[4]=new PdfPCell(new Paragraph("收款人名称",bodyTitleFont));
		rowCell2[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell2[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[4].setMinimumHeight(35);
		rowCell2[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String rcvAcctName = "李四";
		rowCell2[5]=new PdfPCell(new Paragraph(rcvAcctName,bodyFont));
		rowCell2[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell2[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[5].setMinimumHeight(35);
		rowCell2[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell2));
		
		// 第三行
		PdfPCell rowCell3[] = new PdfPCell[6];
		
		rowCell3[1]=new PdfPCell(new Paragraph("开户网点",bodyTitleFont));
		rowCell3[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell3[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell3[1].setMinimumHeight(35);
		rowCell3[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String payerBankName = "河北省农村信用社";
		rowCell3[2]=new PdfPCell(new Paragraph(payerBankName,bodyFont));
		rowCell3[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell3[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell3[2].setMinimumHeight(35);
		rowCell3[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell3[4]=new PdfPCell(new Paragraph("开户网点",bodyTitleFont));
		rowCell3[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell3[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell3[4].setMinimumHeight(35);
		rowCell3[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		String rcvDrecBankName = "xxxxxx";
		rowCell3[5]=new PdfPCell(new Paragraph(rcvDrecBankName,bodyFont));
		rowCell3[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell3[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell3[5].setMinimumHeight(35);
		rowCell3[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell3));
		
		// 第四行
		PdfPCell rowCell4[] = new PdfPCell[6];
		rowCell4[0]=new PdfPCell();
		rowCell4[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[0].setMinimumHeight(35);
		rowCell4[0].disableBorderSide(8);
		rowCell4[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell4[1]=new PdfPCell(new Paragraph("交易金额",bodyTitleFont));
		rowCell4[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[1].setMinimumHeight(35);
		rowCell4[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell4[1].disableBorderSide(4);
		String tranAmt = "12.00";
		String fmtAmt = NumberUtil.decimalFormatMoney(new BigDecimal(tranAmt).doubleValue());
		rowCell4[2]=new PdfPCell(new Paragraph(fmtAmt,bodyFont));
		rowCell4[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[2].setMinimumHeight(35);
		rowCell4[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell4[3]=new PdfPCell();
		rowCell4[3].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[3].setMinimumHeight(35);
		rowCell4[3].disableBorderSide(8);
		rowCell4[3].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell4[4]=new PdfPCell(new Paragraph("金额大写",bodyTitleFont));
		rowCell4[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[4].setMinimumHeight(35);
		rowCell4[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell4[4].disableBorderSide(4);
		String chineseAmt = "十二元";
		rowCell4[5]=new PdfPCell(new Paragraph(chineseAmt,bodyFont));
		rowCell4[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell4[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell4[5].setMinimumHeight(35);
		rowCell4[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell4));
		
		// 第五行
		PdfPCell rowCell5[] = new PdfPCell[6];
		rowCell5[0]=new PdfPCell();
		rowCell5[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[0].setMinimumHeight(35);
		rowCell5[0].disableBorderSide(8);
		rowCell5[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell5[1]=new PdfPCell(new Paragraph("手续费",bodyTitleFont));
		rowCell5[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[1].setMinimumHeight(35);
		rowCell5[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell5[1].disableBorderSide(4);
		String realFee ="0";
		String fmtFee = NumberUtil.decimalFormatMoney(new BigDecimal(realFee).doubleValue());
		rowCell5[2]=new PdfPCell(new Paragraph(fmtFee,bodyFont));
		rowCell5[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[2].setMinimumHeight(35);
		rowCell5[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell5[3]=new PdfPCell();
		rowCell5[3].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[3].setMinimumHeight(35);
		rowCell5[3].disableBorderSide(8);
		rowCell5[3].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell5[4]=new PdfPCell(new Paragraph("交易时间",bodyTitleFont));
		rowCell5[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[4].setMinimumHeight(35);
		rowCell5[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell5[4].disableBorderSide(4);
		String tranTime ="2025-5-14 17:00:00";
		rowCell5[5]=new PdfPCell(new Paragraph(tranTime,bodyFont));
		rowCell5[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell5[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell5[5].setMinimumHeight(35);
		rowCell5[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell5));
		// 第六行
		PdfPCell rowCell6[] = new PdfPCell[6];
		rowCell6[0]=new PdfPCell();
		rowCell6[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[0].setMinimumHeight(35);
		rowCell6[0].disableBorderSide(8);
		rowCell6[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell6[1]=new PdfPCell(new Paragraph("交易状态",bodyTitleFont));
		rowCell6[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[1].setMinimumHeight(35);
		rowCell6[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell6[1].disableBorderSide(4);
		String tranStatus = "1";
		rowCell6[2]=new PdfPCell(new Paragraph("成功",bodyFont));
		rowCell6[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[2].setMinimumHeight(35);
		rowCell6[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell6[3]=new PdfPCell();
		rowCell6[3].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[3].setMinimumHeight(35);
		rowCell6[3].disableBorderSide(8);
		rowCell6[3].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell6[4]=new PdfPCell(new Paragraph("备注",bodyTitleFont));
		rowCell6[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[4].setMinimumHeight(35);
		rowCell6[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell6[4].disableBorderSide(4);
		String tranUse = "xxxx";
		rowCell6[5]=new PdfPCell(new Paragraph(tranUse,bodyFont));
		rowCell6[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell6[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell6[5].setMinimumHeight(35);
		rowCell6[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell6));
		// 第七行
		PdfPCell rowCell7[] = new PdfPCell[6];
		rowCell7[0]=new PdfPCell();
		rowCell7[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[0].setMinimumHeight(35);
		rowCell7[0].disableBorderSide(8);
		rowCell7[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell7[1]=new PdfPCell(new Paragraph("xxx类型",bodyTitleFont));
		rowCell7[1].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[1].setMinimumHeight(35);
		rowCell7[1].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell7[1].disableBorderSide(4);
		rowCell7[2]=new PdfPCell(new Paragraph("xxxxxxxxxx",bodyFont));
		rowCell7[2].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[2].setMinimumHeight(35);
		rowCell7[2].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell7[3]=new PdfPCell();
		rowCell7[3].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[3].setMinimumHeight(35);
		rowCell7[3].disableBorderSide(8);
		rowCell7[3].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		
		rowCell7[4]=new PdfPCell(new Paragraph("回单生成时间",bodyTitleFont));
		rowCell7[4].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[4].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[4].setMinimumHeight(35);
		rowCell7[4].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell7[4].disableBorderSide(4);
		String currTime = "2025-05-14 08:51:00";
		rowCell7[5]=new PdfPCell(new Paragraph(currTime,bodyFont));
		rowCell7[5].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell7[5].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell7[5].setMinimumHeight(35);
		rowCell7[5].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rows.add(new PdfPRow(rowCell7));
		// 第八行
		PdfPCell rowCell8[] = new PdfPCell[6];
		String tip = "此回单仅供参考，实际到账状态以收款方账户交易记录为准。";
		rowCell8[0]=new PdfPCell(new Paragraph(tip,tipFont));
		rowCell8[0].setHorizontalAlignment(Element.ALIGN_CENTER);
		rowCell8[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell8[0].setMinimumHeight(35);
		rowCell8[0].setBorderColor(BaseColor.GRAY); //设置边框颜色为灰色
		rowCell8[0].setColspan(6);
		rows.add(new PdfPRow(rowCell8));		
		
		document.add(transTable);
	}

	private void createLine(Document document) throws DocumentException {
		PdfPTable linesTable = new PdfPTable(1);
		linesTable.setSpacingBefore(5f);
		linesTable.setSpacingAfter(15f);
		linesTable.setWidthPercentage(100);
		PdfPCell cell = new PdfPCell();
		cell.setFixedHeight(10f);
		cell.setBorder(Rectangle.BOTTOM);
		cell.setBorderColor(BaseColor.GRAY);
		cell.setBorderWidthBottom(2f);
		linesTable.addCell(cell);
		document.add(linesTable);
	}

	private void createHeadTable(Document document, Font headTitleFont, Font headFont)
			throws DocumentException, BadElementException, MalformedURLException, IOException {
		//创建表对象
		PdfPTable headTable = new PdfPTable(4);
		headTable.setHorizontalAlignment(Element.ALIGN_CENTER);
		headTable.setWidthPercentage(100); // 宽度100%填充
		float[] headTableColumnWidths= {0.11f,0.39f,0.27f,0.23f};
		headTable.setWidths(headTableColumnWidths);
		//设置行对象
		List<PdfPRow> rows = headTable.getRows();
		//第一行图片
		Image image = Image.getInstance("classpath:image/logo.png");
		image.scaleToFit(180, 30);
		PdfPCell rowCell1[] = new PdfPCell[4];
		rowCell1[0]=new PdfPCell(image);
		rowCell1[0].setHorizontalAlignment(Element.ALIGN_LEFT);
		rowCell1[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell1[0].setMinimumHeight(50);
		rowCell1[0].disableBorderSide(15); //隐藏边框
		rowCell1[0].setColspan(4);
		rows.add(new PdfPRow(rowCell1));
		
		//第二行回单编号
		PdfPCell rowCell2[] = new PdfPCell[4];
		rowCell2[0]=new PdfPCell(new Paragraph("xxx编号：",headTitleFont));
		rowCell2[0].setHorizontalAlignment(Element.ALIGN_LEFT);
		rowCell2[0].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[0].setMinimumHeight(20);
		rowCell2[0].disableBorderSide(15); //隐藏边框
		
		String billCode ="322423";
		rowCell2[1]=new PdfPCell(new Paragraph(billCode,headFont));
		rowCell2[1].setHorizontalAlignment(Element.ALIGN_LEFT);
		rowCell2[1].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[1].setMinimumHeight(15);
		rowCell2[1].disableBorderSide(15); //隐藏边框
		
		rowCell2[2]=new PdfPCell(new Paragraph("交易流水号：",headTitleFont));
		rowCell2[2].setHorizontalAlignment(Element.ALIGN_RIGHT);
		rowCell2[2].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[2].setMinimumHeight(15);
		rowCell2[2].disableBorderSide(15); //隐藏边框
		
		String tranSn = "T2313123";
		rowCell2[3]=new PdfPCell(new Paragraph(tranSn,headFont));
		rowCell2[3].setHorizontalAlignment(Element.ALIGN_RIGHT);
		rowCell2[3].setVerticalAlignment(Element.ALIGN_MIDDLE);
		rowCell2[3].setMinimumHeight(15);
		rowCell2[3].disableBorderSide(15); //隐藏边框
		rows.add(new PdfPRow(rowCell2));
		
		document.add(headTable);
	}
}
